Add PythonDependencyFile trait for polymorphic dependency management#7274
Merged
Jenson3210 merged 26 commits intomainfrom Apr 8, 2026
Merged
Add PythonDependencyFile trait for polymorphic dependency management#7274Jenson3210 merged 26 commits intomainfrom
Jenson3210 merged 26 commits intomainfrom
Conversation
Member
|
In terms of scope I'd say it's unrelated, but flagging it here in case we want to consider a Python variant |
timtebeek
reviewed
Apr 7, 2026
timtebeek
reviewed
Apr 7, 2026
timtebeek
reviewed
Apr 7, 2026
…nd PythonDependencyFile
…rsor walks and list appends
… toString().endsWith() calls
Lombok @with always creates new instances even when values are identical, so reference equality checks fail without explicit value comparison. This caused recipes to take an extra cycle, breaking 5 CI tests.
- null scope now means "all scopes" for all filtering methods (withUpgradedVersions, withRemovedDependencies, withChangedDependency, withDependencySearchMarkers, withPinnedTransitiveDependencies) - withAddedDependencies keeps null = default scope (project.dependencies) since additions need a target location - Add scope/groupName params to withChangedDependency and withPinnedTransitiveDependencies for consistent filtering - Remove restrictive valid scope lists from recipe @option annotations since scope values are now polymorphic across file types (pyproject.toml, requirements.txt, Pipfile) - Add scope-filtering tests for search markers across all implementations
Avoids unnecessary trait matching and lock file print-compare cost when no dependency files need updating.
…e maps Replace manual string slicing with Path.resolveSibling in correspondingPyprojectPath and change ExecutionContext lock file maps from Map<String, String> to Map<Path, String>, eliminating toString() conversions at all call sites.
Use diamond operator, static imports, toList(), and getFirst() in tests. Minor line wrapping cleanup in production code.
timtebeek
approved these changes
Apr 8, 2026
Member
timtebeek
left a comment
There was a problem hiding this comment.
Nice work! I like how this simplifies all the recipe implementations, and unlocks usage downstream to make the correct change each and every time we handle dependencies, no matter how they're defined.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PythonDependencyFiletrait with implementations forPyProjectFile(pyproject.toml),RequirementsFile(requirements.txt), andPipfileFile(Pipfile), providing a polymorphic API for dependency operations: add, upgrade, remove, change, pin transitives, and search markersAddDependency,UpgradeDependencyVersion,RemoveDependency,ChangeDependency, andUpgradeTransitiveDependencyVersionto use the trait instead of duplicating TOML manipulation logic — removing ~800 lines of duplicated codepyproject.toml,requirements.txt, andPipfilefilesRequirementsFilesupports scope-based filename filtering:scope=nullmatches all files,scope=""matchesrequirements.txt,scope="dev"matchesrequirements-dev.txtPipfileFilesupports[packages]and[dev-packages]sections via scope parameter, including inline table dependencies (django = {version = ">=3.2", extras = ["postgres"]})PipfileParserfor parsing Pipfile and attachingPythonResolutionResultmarkers withPackageManager.PipenvTest plan
PythonDependencyFileTest) covering all trait methods, matcher, scope filtering, and static utilitiesPipfileFileTest) covering matcher, upgrade, add, remove, change, and search markers